﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace BingMapsSample.Components
{
    public class SearchResultsController
    {
        //------// Properties \\--------------------------------------------\\

        //------\\ Properties //--------------------------------------------//



        //------// Constructors \\------------------------------------------\\
        public SearchResultsController()
        { }
        //------\\ Constructors //------------------------------------------//



        //------// Methods \\-----------------------------------------------\\
        public List<Place> GetSearchResults(string keyword)
        {
            List<Place> searchResults = null;

            if (HttpContext.Current.Session["SearchResults"] == null)
            {
                searchResults = new BingMapsService().KeywordSearch(keyword);
                HttpContext.Current.Session["SearchResults"] = searchResults;
            }
            else
            {
                searchResults = (List<Place>)HttpContext.Current.Session["SearchResults"];
            }

            return searchResults;
        }


        public void ClearSearchResults()
        {
            HttpContext.Current.Session["SearchResults"] = null;
        }
        //------\\ Methods //-----------------------------------------------//
    }
}
